XMas.GameOver = function (game) {
};

XMas.GameOver.prototype = {
    preload: function () {
        // set background color and preload image
        var self = this;
        this.add.sprite(0, 0, 'background');
        var opa = this.add.sprite(0, 0, 'blackfade1');
        opa.alpha = 0.3;
        var textGameOver = self.add.sprite(self.world.centerX - 238, self.world.centerY - 180, "gameover_text");
        textGameOver.alpha = 0;
        self.add.tween(textGameOver).to({ alpha: 1 }, 2400, Phaser.Easing.Linear.None, true);

        //XMas.Score
        var textScore = self.add.text(self.world.centerX - 100, self.world.centerY - 70, "Score : " + XMas.score.toString());

        //  Centers the text
        //textScore.anchor.set(0.5);
        textScore.align = 'left';

        //  Our font + size
        textScore.font = 'Arial';
        //text.fontWeight = 'bold';
        textScore.fontSize = 35;
        textScore.fill = '#ffffff';
        textScore.alpha = 0;
        self.add.tween(textScore).to({ alpha: 1 }, 2400, Phaser.Easing.Linear.None, true);

        //XMas.Score
        var textBestScore = self.add.text(self.world.centerX - 100, self.world.centerY - 30, "  Best : " + XMas.bestScore);

        //  Centers the text
        // textBestScore.anchor.set(0.5);
        textBestScore.align = 'left';

        //  Our font + size
        textBestScore.font = 'Arial';
        //text.fontWeight = 'bold';
        textBestScore.fontSize = 35;
        textBestScore.fill = '#ffffff';
        textBestScore.alpha = 0;
        self.add.tween(textBestScore).to({ alpha: 1 }, 2400, Phaser.Easing.Linear.None, true);

        // add the button that will start the game
        //  This sprite is using a texture atlas for all of its animation data
        var startButton = this.add.sprite(XMas.GlobalVariables.GAME_WIDTH / 2 - 95, XMas.GlobalVariables.GAME_HEIGHT - 200, 'button-try');
        //  Here we add a new animation called 'run'
        //  We haven't specified any frames because it's using every frame in the texture atlas
        startButton.animations.add('run');
        //  And this starts the animation playing by using its key ("run")
        //  5 is the frame rate (5fps)
        //  true means it will loop when it finishes
        startButton.animations.play('run', 5, true);
        startButton.inputEnabled = true;
        startButton.input.useHandCursor = true;
        startButton.events.onInputDown.add(this.startGame, this);

        // add transition when change page
        var blackFade = this.add.sprite(0, 0, "blackfade");
        XMas.Effect.transitionPage(blackFade, 1000, 0, this);

    },
    create: function () {
        // start the MainMenu state
        //this.state.start('bo');
		if (XMas.score > XMas.bestScore) {
            XMas.Util.postBestScore();
         }
    },
    startGame: function () {
        // start the Game state
        this.state.start('Boot');
        //this.state.destroy();
    }

};